//
//  MeViewController.m
//  Cat
//
//  Created by lushitong on 2018/11/29.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "MeViewController.h"
#import "MeTableView.h"
#import "HttpUserManager.h"

@interface MeViewController ()

@property (nonatomic, strong) MeTableView *tableView;

@end

@implementation MeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	[self loadAllSubviews];
	self.topTitleView.backgroundColor = [UIColor clearColor];
	self.topTitleView.bottomLineView.backgroundColor  = [UIColor clearColor];
	[self.view bringSubviewToFront:self.topTitleView];
}

- (void)loadAllSubviews {
	[self.view addSubview:self.tableView];
}

- (void)viewWillAppear:(BOOL)animated {
	[super viewWillAppear:animated];
	[self sendRequest];
}

- (void)sendRequest {
	NSLog(@"%@",UDToken);
	if (UDToken.length == 0) {
		FMDBUser *user = [[FMDBUser alloc] init];
		[self.tableView setUser:user];
		return;
	}
	[HttpUserManager getUserInfsuccess:^(FMDBUser * _Nonnull user) {
		[self.tableView setUser:user];
	} failure:^(NSInteger code, NSString * _Nonnull message) {
		[FLProgressHUD showError:message];
	}];
}
#pragma mark----- lazy init -----

- (MeTableView *)tableView {
	if (!_tableView) {
		_tableView = [[MeTableView alloc] initWithFrame:CGRectMake(0.0, - StatusBarHeight + StatusBarSafeInsetHeight, ScreenWidth, ScreenHeight - StatusBarHeight - kQKFitModuleDecimal(10.0)) sections:2];
	}
	return _tableView;
}

@end
